/*
 * File:   LineUnitTest.cpp
 * Author: Guilherme Monteiro
 *
 */

#include "LineUnitTest.h"
#include "../headers/Line.h"


CPPUNIT_TEST_SUITE_REGISTRATION(LineUnitTest);

LineUnitTest::LineUnitTest() {
}

LineUnitTest::~LineUnitTest() {
}

void LineUnitTest::setUp() {
}

void LineUnitTest::tearDown() {
}

void LineUnitTest::testLine() {
    Line line;
    
    CvPoint r1 = line.p1;
    CvPoint r2 = line.p2;
    if (!(r1.x == -1 && r1.y == -1 && r2.x == -1 && r2.y == -1)) {
        CPPUNIT_ASSERT(false);
    }
}

void LineUnitTest::testEquals() {
    CvPoint p1 = cvPoint(1,1);
    CvPoint p2 = cvPoint(1,1);
    CvPoint p3 = cvPoint(1,1);
    CvPoint p4 = cvPoint(1,1);    
    
    Line otherLine(p1,p2);
    Line line(p3,p4);
    bool result = line.equals(otherLine);
    if (!result) {
        CPPUNIT_ASSERT(false);
    }
}

void LineUnitTest::testIntersection() {
    CvPoint p1 = cvPoint(3,2);
    CvPoint p2 = cvPoint(3,5);
    CvPoint p3 = cvPoint(3,4);
    CvPoint p4 = cvPoint(6,4);    
    
    Line otherLine(p1,p2);
    Line line(p3,p4);
    CvPoint result = line.intersection(otherLine);
    
    if (result.x != 3 || result.y != 4 ) {
        CPPUNIT_ASSERT(false);
    }
}

void LineUnitTest::testIsHorizontal() {
    CvPoint p1 = cvPoint(1,2);
    CvPoint p2 = cvPoint(4,2);
    
    Line line(p1,p2);
    bool result = line.isHorizontal();
    if (!result) {
        CPPUNIT_ASSERT(false);
    }
}

void LineUnitTest::testIsVertical() {
    CvPoint p1 = cvPoint(3,4);
    CvPoint p2 = cvPoint(3,7);
    
    Line line(p1,p2);
    bool result = line.isVertical();
    if (!result) {
        CPPUNIT_ASSERT(false);
    }
}

